import Constants from '../constants/Constants'
import Dispatcher from '../Dispatcher'
import {EventEmitter} from 'events'
import merge from 'lodash.merge'

const ActionTypes = Constants.ActionTypes

let user = {}

let UserStore = merge({}, EventEmitter.prototype, {
  setUser: data => {
    user = data
  },
  
  getUser: () => {
    return user
  }
})

Dispatcher.register(action => {
  switch (action.type) {
    case ActionTypes.CHECK:
      UserStore.setUser(action.data)
      break;
  }
})

export default UserStore
